<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0063)http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script async="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/analytics.js"></script>

<title>使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园</title>
<link type="text/css" rel="stylesheet" href="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/blog-common.css">
<link id="MainCss" type="text/css" rel="stylesheet" href="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/bundle-AnotherEon001.css">
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/nokiaguy/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/nokiaguy/rsd.xml">
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/nokiaguy/wlwmanifest.xml">
<script async="" type="text/javascript" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/gpt.js"></script><script src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/jquery.js" type="text/javascript"></script>  
<script type="text/javascript">var currentBlogApp = 'nokiaguy', cb_enable_mathjax=false;</script>
<script src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/blog-common.js" type="text/javascript"></script>
<script async="" type="text/javascript" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/pubads_impl_50.js"></script><style type="text/css">#yddContainer{display:block;font-family:Microsoft YaHei;position:relative;width:100%;height:100%;top:-4px;left:-4px;font-size:12px;border:1px solid}#yddTop{display:block;height:22px}#yddTopBorderlr{display:block;position:static;height:17px;padding:2px 28px;line-height:17px;font-size:12px;color:#5079bb;font-weight:bold;border-style:none solid;border-width:1px}#yddTopBorderlr .ydd-sp{position:absolute;top:2px;height:0;overflow:hidden}.ydd-icon{left:5px;width:17px;padding:0px 0px 0px 0px;padding-top:17px;background-position:-16px -44px}.ydd-close{right:5px;width:16px;padding-top:16px;background-position:left -44px}#yddKeyTitle{float:left;text-decoration:none}#yddMiddle{display:block;margin-bottom:10px}.ydd-tabs{display:block;margin:5px 0;padding:0 5px;height:18px;border-bottom:1px solid}.ydd-tab{display:block;float:left;height:18px;margin:0 5px -1px 0;padding:0 4px;line-height:18px;border:1px solid;border-bottom:none}.ydd-trans-container{display:block;line-height:160%}.ydd-trans-container a{text-decoration:none;}#yddBottom{position:absolute;bottom:0;left:0;width:100%;height:22px;line-height:22px;overflow:hidden;background-position:left -22px}.ydd-padding010{padding:0 10px}#yddWrapper{color:#252525;z-index:10001;background:url(chrome-extension://eopjamdnofihpioajgfdikhhbobonhbb/ab20.png);}#yddContainer{background:#fff;border-color:#4b7598}#yddTopBorderlr{border-color:#f0f8fc}#yddWrapper .ydd-sp{background-image:url(chrome-extension://eopjamdnofihpioajgfdikhhbobonhbb/ydd-sprite.png)}#yddWrapper a,#yddWrapper a:hover,#yddWrapper a:visited{color:#50799b}#yddWrapper .ydd-tabs{color:#959595}.ydd-tabs,.ydd-tab{background:#fff;border-color:#d5e7f3}#yddBottom{color:#363636}#yddWrapper{min-width:250px;max-width:400px;}</style><meta name="chromesniffer" id="chromesniffer_meta" content="{&quot;jQuery&quot;:&quot;1.7&quot;}"><script type="text/javascript" src="chrome-extension://homgcnaoacgigpkkljjjekpignblkeae/detector.js"></script><script type="text/javascript" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/osd.js"></script></head>
<body>
<a name="top"></a>

<div id="wrapper">
<div id="header">

<div id="top">
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/nokiaguy/">李宁的极客世界</a></h1>
<div id="subtitle"></div>
</div>
<div id="sub">
<div class="BlogStats">随笔 - 146, 文章 - 0, 评论 - 1192, 引用 - 29</div>
</div>



</div>
<div id="main_container">
<div id="main_content">
<div id="content">
	

	<div class="post">
		<h2>
			<a id="cb_post_title_url" href="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园.htm">使用.Net的CodeDOM技术实现语言无关的Code Wizard</a>
		</h2>
		<div class="postbody">
		<div id="cnblogs_post_body"><span style="font-size: 14pt;"><span style="font-size: 12pt;"><strong style="color: red;">本文为原创，如需转载，请注明作者和出处，谢谢！<br>
</strong></span></span>
<br>
<strong>本文曾发表于It168：<a target="_blank" href="http://tech.it168.com/m/2007-09-11/200709111500188.shtml">http://tech.it168.com/m/2007-09-11/200709111500188.shtml</a></strong><br>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">摘要：CodeDOM是<span>.net
framework</span>的一项重要的源代码生成技术。本文详细讨论了CodeDOM的原理以及如何利用CodeDOM技术实现一个与语言无关的Code Wizard。并给出了一个用C#语言实现的例子。</span></p>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">关键字：Code Wizards、CodeDOM、</span><span style="font-family: 新宋体; color: black;">.net framework</span><span style="font-family: 新宋体; color: black;">、</span><span style="font-family: 宋体;">数据表、模板文件</span></p>
<p><strong><span style="font-family: 宋体; color: rgb(255, 102, 0);"><span style="color: rgb(0, 0, 0);">一、什么是CodeDom?</span></span></strong></p>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">现在的程序规模越来越大，虽然在计算发展的几十年间，产生了许多快捷、高效的编程语言和开发工具，如C#、Visual Studio、java等。也产生了许多用以辅助软件设计、开发的思想和方法，如UML、OOP、Agile等。尽管利用这些技术和方法可以大大提高程序编写的效率，但是仍可能有重复的编码工作。因此，现在出现了许多可以自动产生源代码或者目标文件的软件，即Code Wizards。<span><br>
&nbsp;&nbsp;&nbsp; </span>一般这些<span>Code
Wizards</span>在生成源代码时都是通过设置模板文件，然后根据这些模板文件生成源代码。有很多Code Wizards只能生成固定的语言（如java、C#等）。虽然有一些<span>Code
Wizards</span>可以生成多种语言，但也只是固定的几种。而且生成源代码部分都是显示地固定在程序中。这样非常不易扩展。如CodeSmith系统，这是一个非常不错的Code Wizard。它使用一个扩展名为cst的文件来设置模板。这个模板文件的格式类似于Asp.net。如果想生成C#源代码，必须要在其中显示地标明，并且模板的固定部分要使用C#语言编写。如果这样的话，同样功能要生成不同语言的代码，如C#和VB.net。就要编写两个模板文件。这是非常不方便的。<span><br>
&nbsp;&nbsp;&nbsp; </span>从以上的描述来看， <span>Code
Wizard</span>所面临的一个重要问题就是如何使用一个模版文件来生成不同语言的源代码。幸好Microsoft提供了一种解决方案，这就是CodeDOM技术。CodeDOM的全称是代码文档对象模型(Code Document Object Model)。整个CodeDOM就是一张对象图(object graph)。它用这张图中的所有对象描述了面向对象语言中的几乎所有的语法现象，如类、接口、方法、属性等。</span><span style="font-family: 新宋体; color: black;">CodeDOM</span><span style="font-family: 新宋体; color: black;">通过对象模型对语言进行了抽象，然后利用具体语言所提供的生成源代码的机制来生成源代码，并可调用相应的编译器将源码生成*.dll或*.exe。从而可以达到与语言无关的目的。图1</span><span style="font-family: 宋体;">描述了使用</span><span style="font-family: 新宋体; color: black;">CodeDOM</span><span style="font-family: 宋体;">生成和编译源代码的过程。<br>
<br>
<img alt="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/01_codedom.jpg" height="384" width="324"><br>
<br>
</span>
</p>
<p style="text-indent: 115.5pt;"><span style="font-family: 宋体;">图1&nbsp;CodeDom生成和编译源代码的过程</span></p>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">从上图可以看出，CodeWizard只使用CodeDOM对语言进行抽象，然后通过CodeDomProvider生成源代码。最后通过编译器生成中间语言。下面将详细讨论如何利用CodeDOM来实现CodeWizard。</span></p>
<p><strong><span style="font-family: 宋体; color: rgb(255, 102, 0);"><span style="color: red;"><span style="color: rgb(0, 0, 0);">二、实现CodeWizard</span></span></span></strong></p>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">下面要实现的这个CodeWizard非常简单。其功能主要是将一个数据表映射成一个类。这个类提供了Add和Save方法以及和数据表的每个字段相对应的属性。使用这个类可以向数据表添加记录。为了便于描述，将这个数据表保存成xml文件格式。每条记录为一个item结点，每一个字段为这个结点的一个属性。表名为这个xml文件的根结点名称。这个xml文件的格式如下所示：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MyTable</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">item&nbsp;</span><span style="color: rgb(255, 0, 0);">id&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"01&nbsp;"</span><span style="color: rgb(255, 0, 0);">&nbsp;name&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"Bill&nbsp;"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">item&nbsp;</span><span style="color: rgb(255, 0, 0);">id&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"02"</span><span style="color: rgb(255, 0, 0);">&nbsp;name&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"Mike"</span><span style="color: rgb(255, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">MyTable</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span></div>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">这个CodeWizard通过一个模板文件来定义数据表的结构。模板文件的格式如下：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MyTable</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">id&nbsp;</span><span style="color: rgb(255, 0, 0);">type&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"System.Int32"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">name&nbsp;</span><span style="color: rgb(255, 0, 0);">type&nbsp;</span><span style="color: rgb(0, 0, 255);">=&nbsp;"System.String"</span><span style="color: rgb(0, 0, 255);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">MyTable</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span></div>
<br>
<p style="text-indent: 21pt;"><span style="font-family: 宋体;">其中type为字段的类型，它的值是在.net framework中的System中定义的简单类型，如System.Int32、System.String、System.Char等。下面就详细讨论如何利用这个模板文件和CodeDOM技术来生成C#和VB.net的源代码。<br>
<span><br>
<strong><span style="color: rgb(0, 0, 0);">三、CodeDOM的结构</span></strong> </span></span></p>
<p><span style="font-family: 宋体;">CodeDOM</span><span style="font-family: 宋体;">由两部分组成：</span></p>
<p style="text-indent: 21pt;"><span style="font-family: 新宋体; color: black;">1. </span><span style="font-family: 新宋体; color: black;">用于描述抽象代码结构的一组类。其中</span><span style="font-family: 新宋体; color: teal;">CodeCompileUnit</span><span style="font-family: 新宋体; color: black;">类是这些类的根。代表一个源码文件（如C#的*.cs和VB.net的*.vb）。在使用CodeDOM时，必须先建立一个</span><span style="font-family: 新宋体; color: teal;">CodeCompileUnit</span><span style="font-family: 新宋体; color: black;">类的对象，然后在这个对象中加入必要的namespace、class等面向对象元素。</span></p>
<p style="margin-left: 39pt; text-indent: -18pt;"><span style="font-family: 宋体;">用于生成和编译源代码的类。这个类必须从</span><span style="font-family: 新宋体; color: teal;">CodeDomProvider</span><span style="font-family: 宋体;">类继承。每种<span>.net
framework</span></span></p>
<p><span style="font-family: 宋体;">所支持的语言都有自己的</span><span style="font-family: 新宋体; color: teal;">CodeDomProvider</span><span style="font-family: 宋体;">类。如在C#中的</span><span style="font-family: 新宋体; color: teal;">CodeDomProvider</span><span style="font-family: 宋体;">类叫</span><span style="font-family: 新宋体; color: teal;">CSharpCodeProvider</span><span style="font-family: 宋体;">，而在VB.net中叫</span><span style="font-family: 新宋体; color: teal;">VBCodeProvider</span><span style="font-family: 宋体;">。<br>
<br>
</span>
</p>
<p><strong><span style="font-family: 宋体; color: rgb(255, 102, 0);"><span style="color: rgb(0, 0, 0);">四、数据表类的定义</span></span></strong></p>
<p><span style="font-family: 宋体;">要用CodeDOM定义一个类需要三步：</span></p>
<p style="margin-left: 21pt;"><span style="font-family: 宋体;">1. </span><span style="font-family: 宋体;">建立一个</span><span style="font-family: 新宋体; color: teal;">CodeCompileUnit</span><span style="font-family: 新宋体; color: black;">对象。这个类相当于一个源码文件。</span></p>
<p style="margin-left: 21pt;"><span style="font-family: 新宋体; color: black;">2. </span><span style="font-family: 新宋体; color: black;">建立一个</span><span style="font-family: 新宋体; color: teal;">CodeNamespace</span><span style="font-family: 新宋体; color: black;">对象。理论上在<span>.net
framework</span>上运行的程序语言，如C#、VB.net</span></p>
<p><span style="font-family: 新宋体; color: black;">等，可以没有namespace。但在CodeDOM中必须使用这个类，如果不想要namespace，可以将namespace的名字设为 null或空串。</span></p>
<p style="margin-left: 39pt; text-indent: -18pt;"><span style="font-family: 新宋体; color: black;">建立一个</span><span style="font-family: 新宋体; color: teal;">CodeTypeDeclaration</span><span style="font-family: 新宋体; color: black;">对象。这个类可以建立Class和Interface两种Type。在</span></p>
<p><span style="font-family: 新宋体; color: black;">这个例子中只建立Class。如果想建立Interface，只需将</span><span style="font-family: 新宋体;">IsInterface</span><span style="font-family: 新宋体;">属性设为true即可。</span></p>
<p style="margin-left: 21pt;"><span style="font-family: 新宋体;">主要的实现代码如下:</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeCompileUnit&nbsp;m_CodeCompileUnit;<br>
</span><span style="color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeNamespace&nbsp;m_CodeNameSpace;<br>
</span><span style="color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeTypeDeclaration&nbsp;m_Class;<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;InitCodeDom()<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_CodeCompileUnit&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeCompileUnit();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_CodeNameSpace&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeNamespace(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xml.tables</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_CodeCompileUnit.Namespaces.Add(m_CodeNameSpace);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Class&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeTypeDeclaration(m_ClassName);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_CodeNameSpace.Types.Add(m_Class);<br>
}<br>
</span></div>
<br>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 新宋体;">其中namespace的名子是“xml.tables”。在建立完namespace后，将其加入到m_CodeCompileUnit的Namespaces集合中。m_ClassName是一个String变量，它的值就是数据表的表名。最后将所建立的类加入到namespace的Types集合中。在产生完类后。需要在这个类中加入四部分内容，它们分别是：全局变量、属性、构造函数和方法（Add和Save方法）。下面就分别讨论它们的实现过程。</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: 新宋体; color: rgb(255, 102, 0);"><span style="color: rgb(0, 0, 0);">五、全局变量的生成</span></span></strong></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 新宋体;">这个数据表类中有四种全局变量：用于操作xml文件的类型为XmlDocument的变量、用于保存数据表文件名的变量、用于确定是否为加入状态的Boolean型变量、以及用于保存每个字段值的变量组。具体实现代码如下：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;GenerateFields()<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"private&nbsp;XmlDocument&nbsp;m_xml&nbsp;=&nbsp;new&nbsp;XmlDocument();"&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;xml&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberField(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.XmlDocument</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_xml</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp; CodeObjectCreateExpression&nbsp;createxml&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeObjectCreateExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.XmlDocument</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;xml.InitExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;createxml;<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(xml);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"private&nbsp;String&nbsp;m_XmlFile;"&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;xmlfile&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberField(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.String</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_XmlFile</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(xmlfile);<br>
</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;根据模板文件产生保存字段值的变量</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;
</span><span style="color: rgb(0, 0, 0);">String&nbsp;fieldname&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">,&nbsp;fieldtype&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(XmlNode&nbsp;xn&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;m_Xml.DocumentElement.ChildNodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fieldname&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;xn.Name;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fieldtype&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;xn.Attributes[</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">type</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">].Value;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;field&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberField(fieldtype,&nbsp;fieldname);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(field);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"private&nbsp;bool&nbsp;m_AddFlag;"&nbsp;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberField&nbsp;addflag&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberField(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Boolean</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_AddFlag</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(addflag);<br>
}<br>
</span></div>
<br>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 新宋体;">在以上代码中每段程序上方的注释是它们所生成的C#源代码。在输入这段代码之前，需要引入两个namespace。<br>
</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System.CodeDom;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System.CodeDom.Compiler;<br>
</span></div>
<br>
<p style="text-align: left;" align="left"><strong><span style="font-family: 新宋体; color: rgb(255, 102, 0);"><span style="color: rgb(0, 0, 0);">五、属性的生成</span></span></strong></p>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 新宋体;">在数据表类中每个属性代表数据表的一个字段，名子就是字段名。这些属性和保存字段的全局变量一一对应。下面是具体的实现代码：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;GenerateProperties()<br>
{<br>
&nbsp;&nbsp;&nbsp; String&nbsp;fieldname&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">,&nbsp;fieldtype&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(XmlNode&nbsp;xn&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;m_Xml.DocumentElement.ChildNodes)<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fieldname&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;xn.Name;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fieldtype&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;xn.Attributes[</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">type</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">].Value;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberProperty&nbsp;property&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberProperty();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.Attributes&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Public&nbsp;</span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Final;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.Name&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;fieldname;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.Type&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeTypeReference(fieldtype);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.HasGet&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.HasSet&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeVariableReferenceExpression&nbsp;field&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;fieldname);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;return&nbsp;m_property</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodReturnStatement&nbsp;propertyReturn&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodReturnStatement(field);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.GetStatements.Add(propertyReturn);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;m_property&nbsp;=&nbsp;value;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;propertyAssignment&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(field, </span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePropertySetValueReferenceExpression());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;property.SetStatements.Add(propertyAssignment);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(property);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
</span></div>
<br>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 新宋体;">这些生成的属性是可读写的。这就需要将HasGet和HasSet两个属性设为true，然后分别将get和set方法中的语句分别加到GetStatements和SetStatements中。</span></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><span style="color: rgb(0, 0, 0);">六、构造函数的生成</span></span></strong></p>
<p style="text-align: left;" align="left"><strong><span style="font-family: 新宋体; color: rgb(255, 102, 0);">&nbsp;&nbsp;&nbsp; </span></strong><span style="font-family: 新宋体;">构造函数的主要工作是打开数据表。如果数据表不存在，就创建这个数据表文件。在编写代码之前，需要先定义三个全局变量。因为这三个全局变量在程序中会多次用到。它们的类型都是<span style="color: teal;">CodeVariableReferenceExpression</span><span style="color: teal;">。</span><span style="color: black;">这个类型变量其实在生成源码中的作用就是对某一个变量的引用。具体的实现代码如下：</span></span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression&nbsp;m_XmlFileExpression;<br>
</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression&nbsp;m_XmlExpression;<br>
</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression&nbsp;m_AddFlagExpression;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;InitVariants()<br>
{<br>
m_XmlFileExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_XmlFile</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_XmlExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_xml</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_AddFlagExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_AddFlag</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
}<br>
</span></div>
<br>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">下面是生成构造函数的源代码：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;GenerateConstructor()<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;定义构造函数</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeConstructor&nbsp;constructor&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeConstructor();<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Parameters.Add(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeParameterDeclarationExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.String</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xmlFile</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Attributes&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Public;<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_XmlFile&nbsp;=&nbsp;xmlFile;"&nbsp;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignXmlFile&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(m_XmlFileExpression, </span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xmlFile</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_xml.LoadXml("…");"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeLoadXml&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">LoadXml</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, <br>
</span><span style="color: rgb(0, 0, 255);">&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&lt;?xml&nbsp;version=\</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 128);">1.0</span><span style="color: rgb(0, 0, 0);">\</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&nbsp;encoding=\</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">gb2312\</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&nbsp;?&gt;&lt;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;m_Xml.DocumentElement.Name </span><span style="color: rgb(0, 0, 0);"><br>
&nbsp;&nbsp; +</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;m_Xml.DocumentElement.Name&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&gt;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_xml.Save(m_XmlFile);"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeSave&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">Save</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, <br>
&nbsp;&nbsp;&nbsp; m_XmlFileExpression);<br>
&nbsp;&nbsp;&nbsp;&nbsp;CodeStatementCollection&nbsp;statements&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeStatementCollection();<br>
&nbsp;&nbsp;&nbsp;&nbsp;statements.Add(invokeLoadXml);<br>
&nbsp;&nbsp;&nbsp;&nbsp;statements.Add(invokeSave);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生if语句:&nbsp;&nbsp;"if&nbsp;(System.IO.File.Exists(m_XmlFile))&nbsp;<img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/dot.gif" alt="">&nbsp;else&nbsp;<img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/dot.gif" alt="">&nbsp;"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeConditionStatement&nbsp;ifStatement&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeConditionStatement(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(</span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.IO.File</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">Exists</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;m_XmlFileExpression),&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeStatement[]&nbsp;{&nbsp;}&nbsp;, <br>
</span><span style="color: rgb(0, 0, 255);">&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeStatement[]&nbsp;{&nbsp;statements[</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">],&nbsp;statements[</span><span style="color: rgb(128, 0, 128);">1</span><span style="color: rgb(0, 0, 0);">]&nbsp;});<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_xml.Load(m_XmlFile);"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeLoad&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">Load</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,<br>
&nbsp; &nbsp;&nbsp; m_XmlFileExpression);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_AddFlag&nbsp;=&nbsp;false;"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignAddFalse&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(m_AddFlagExpression, <br>
</span><span style="color: rgb(0, 0, 255);">&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Statements.Add(assignXmlFile);<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Statements.Add(ifStatement);<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Statements.Add(invokeLoad);<br>
&nbsp;&nbsp;&nbsp;&nbsp;constructor.Statements.Add(assignAddFalse);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(constructor);<br>
}<br>
</span></div>
<strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><span style="color: rgb(0, 0, 0);"><strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><span style="color: rgb(0, 0, 0);"><strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><br>
</span></strong><strong></strong></span></span></strong><strong></strong></span></span></strong>
<p><strong><span style="color: rgb(0, 0, 0);">七、Add和Save方法生成</span></strong><br>
<strong></strong></p>
<p style="text-indent: 21pt;"><span style="font-family: 新宋体;">Add</span><span style="font-family: 新宋体;">方法只有一条语句，功能是将m_AddFlag设为true，以使数据表类处于加入状态。Save方法比较复杂。它的功能是当m_AddFlag为true时在数据表文件的最后加入一条记录，并保存。具体实现代码如下：</span></p>
<strong></strong><br>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;GenerateMethods()<br>
{<br>
CodeTypeReference&nbsp;voidReference&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeTypeReference(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.void</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">产生Add方法</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberMethod&nbsp;add&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberMethod();<br>
&nbsp;&nbsp;&nbsp;&nbsp;add.ReturnType&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;voidReference;<br>
&nbsp;&nbsp;&nbsp;&nbsp;add.Name&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">add</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;add.Attributes&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Public&nbsp;</span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Final;<br>
&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignAddTrue&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(m_AddFlagExpression, <br>
&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;&nbsp;add.Statements.Add(assignAddTrue);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(add);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">产生Save方法</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMemberMethod&nbsp;save&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMemberMethod();<br>
&nbsp;&nbsp;&nbsp;save.ReturnType&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;voidReference;<br>
&nbsp;&nbsp;&nbsp;save.Name&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">save</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;save.Attributes&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Public&nbsp;</span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);">&nbsp;MemberAttributes.Final;<br>
&nbsp;&nbsp;&nbsp;System.Collections.Generic.List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">CodeStatement</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;ifStatements&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> <br>
&nbsp;&nbsp; </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;System.Collections.Generic.List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">CodeStatement</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">产生&nbsp;"XmlNode&nbsp;xn&nbsp;=&nbsp;m_xml.CreateNode(XmlNodeType.Element,&nbsp;"item",&nbsp;"");"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;CodeVariableDeclarationStatement&nbsp;xmlNode&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableDeclarationStatement(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.XmlNode</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xn</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;createNode&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">CreateNode</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp; <br>
</span><span style="color: rgb(0, 0, 255);">&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeExpression[]&nbsp;{</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.XmlNodeType.Element</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">), <br>
&nbsp; </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">item</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">), </span><span style="color: rgb(0, 0, 255);"><br>
&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(128, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">)&nbsp;});<br>
&nbsp;&nbsp;&nbsp;xmlNode.InitExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;createNode;<br>
&nbsp;&nbsp;&nbsp;ifStatements.Add(xmlNode);<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">产生&nbsp;"XmlAttribute&nbsp;xa&nbsp;=&nbsp;null;&nbsp;"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;CodeVariableDeclarationStatement&nbsp;xmlAttr&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableDeclarationStatement(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.XmlAttribute</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xa</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;xmlAttr.InitExpression&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;ifStatements.Add(xmlAttr);<br>
</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">产生字段属性</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;CodeStatementCollection&nbsp;statements&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeStatementCollection();<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(XmlNode&nbsp;xn&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;m_Xml.DocumentElement.ChildNodes)<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;createAttribute&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">CreateAttribute</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(xn.Name));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignxa&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(</span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xa</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),&nbsp;createAttribute);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeToString&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(</span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">&nbsp;xn.Name), </span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">ToString</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignValue&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xa.Value</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),&nbsp;invokeToString);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeAppend&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(</span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xn.Attributes</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">), <br>
</span><span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "</span><span style="color: rgb(128, 0, 0);">Append</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xa</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statements.Add(invokeAppend);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ifStatements.Add(assignxa);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ifStatements.Add(assignValue);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ifStatements.Add(statements[</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">]);<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_xml.DocumentElement.AppendChild(xn);"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeAppendChild&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> <br>
&nbsp; CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">m_xml.DocumentElement</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">AppendChild</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 255);"><br>
&nbsp;&nbsp; new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeVariableReferenceExpression(</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">xn</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;statements.Clear();<br>
&nbsp;&nbsp;&nbsp;statements.Add(invokeAppendChild);<br>
&nbsp;&nbsp;&nbsp;&nbsp;ifStatements.Add(statements[</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_xml.Save(m_XmlFile);"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeMethodInvokeExpression&nbsp;invokeSave&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeMethodInvokeExpression(m_XmlExpression, <br>
&nbsp;&nbsp; </span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">Save</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;m_XmlFileExpression);<br>
&nbsp;&nbsp;&nbsp;&nbsp;statements.Clear();<br>
&nbsp;&nbsp;&nbsp;&nbsp;statements.Add(invokeSave);<br>
&nbsp;&nbsp;&nbsp;&nbsp;ifStatements.Add(statements[</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生&nbsp;"m_AddFlag&nbsp;=&nbsp;false;"&nbsp;</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeAssignStatement&nbsp;assignAddFalse&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeAssignStatement(m_AddFlagExpression,<br>
&nbsp; &nbsp; </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodePrimitiveExpression(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">));<br>
&nbsp;&nbsp;&nbsp;
ifStatements.Add(assignAddFalse);<br>
</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;产生if语句:&nbsp;"if&nbsp;(m_AddFlag)"</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;CodeConditionStatement&nbsp;ifStatement&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeConditionStatement(m_AddFlagExpression, <br>
&nbsp;&nbsp;&nbsp; ifStatements.ToArray());<br>
&nbsp;&nbsp;&nbsp;&nbsp;save.Statements.Add(ifStatement);<br>
&nbsp;&nbsp;&nbsp;&nbsp;m_Class.Members.Add(save);<br>
}<br>
</span></div>
<br>
<p><strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><span style="color: rgb(0, 0, 0);">八、生成源代码</span></span></strong></p>
<p style="text-indent: 21pt;"><span style="font-family: 新宋体;">生成具体语言的源代码需要一个从<span style="color: teal;">CodeDomProvider</span>继承的类。对于C#而言是<span style="color: teal;">CSharpCodeProvider</span>类。实现代码如下：</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Microsoft.CSharp;<br>
</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;SaveCSharp(String&nbsp;filename)<br>
{<br>
IndentedTextWriter&nbsp;tw&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;IndentedTextWriter(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;StreamWriter(filename,&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">),&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;CodeDomProvider&nbsp;provide&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CSharpCodeProvider();&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;provide.GenerateCodeFromCompileUnit(m_CodeCompileUnit,&nbsp;tw,&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CodeGeneratorOptions());<br>
&nbsp;&nbsp;&nbsp;&nbsp;tw.Close();<br>
}<br>
</span></div>
<p style="text-indent: 21pt;">
</p>
<p style="text-align: left; text-indent: 18pt;" align="left"><span style="font-family: 新宋体;">在使用<span style="color: teal;">CSharpCodeProvider</span>类时需要用到m_CodeCompileUnit这个全局变量。这样可产生一个*.cs文件。以上代码中的<span style="color: teal;">IndentedTextWriter</span>类是建立一个文件的Writer，用于向这个文件中输出源代码。但和其它的Writer不同的是它的输出是缩进的（以四个空格进行缩进）。如是想生成VB.net的代码，只需将<span style="color: teal;">CSharpCodeProvider</span>改为<span style="color: teal;">VBCodeProvider</span>即可。</span></p>
<p><strong><span style="font-family: 新宋体; color: rgb(255, 153, 0);"><span style="color: rgb(0, 0, 0);">九、编译源代码</span></span></strong></p>
<p style="text-align: left; text-indent: 18pt;" align="left"><span style="font-family: 新宋体;">到现在为止，这个数据表类的源代码已经全部生成了。你可以将这个源文件直接加入到自己的工程中。或者直接将其编译成*.dll文件，然后在程序中调用。如果想编译，可以直接调用指定语言的编译器（如C#中的csc.exe）。但这样不是太方便。在CodeDOM中提供了一种机制，可以在程序中通过CodeDomProvider直接调用指定语言的编译器。下面是编译C#源程序的一个例子。</span></p>
<br>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;CompileCSharp(String&nbsp;sourcefile,&nbsp;String&nbsp;targetFile)<br>
{<br>
CompilerParameters&nbsp;cp&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CompilerParameters(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;String[]&nbsp;{&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">System.Xml.dll</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;},&nbsp;&nbsp;targetFile,&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;CodeDomProvider&nbsp;provider&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;CSharpCodeProvider();<br>
&nbsp;&nbsp;&nbsp;cp.GenerateExecutable&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;调用编译器</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;CompilerResults&nbsp;cr&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;provider.CompileAssemblyFromFile(cp,&nbsp;sourcefile);<br>
&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;(cr.Errors.Count&nbsp;</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">0</span><span style="color: rgb(0, 0, 0);">)<br>
&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;显示编译错误</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">&nbsp;(CompilerError&nbsp;ce&nbsp;</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">&nbsp;cr.Errors)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Windows.Forms.MessageBox.Show(ce.ToString());<br>
&nbsp;&nbsp;&nbsp;}<br>
}<br>
</span></div>
<br>
<p style="text-align: left; text-indent: 18pt;" align="left"><span style="font-family: 新宋体;">对于以上代码有两点说明：</span></p>
<ol style="margin-top: 0cm;" start="1" type="1">
    <li style="text-align: left;"><span style="font-family: 新宋体;">使用CodeDomProvider调用编译器时也需要传递相应的参数，如在本例中将System.Xml.dll</span></li>
</ol>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">作为一个参数，表示目标文件需要调用这个dll中的资源。</span></p>
<ol style="margin-top: 0cm;" start="2" type="1">
    <li style="text-align: left;"><span style="font-family: 新宋体;">在调用编译器后，如果出现错误，可使用cr.Errors获得错误信息。</span></li>
</ol>
<p style="text-align: left;" align="left"><strong><span style="font-family: 新宋体; color: rgb(255, 102, 0);"><span style="color: rgb(0, 0, 0);">十、结束语</span></span></strong></p>
<p style="text-align: left; text-indent: 21pt;" align="left"><span style="font-family: 新宋体;">我花了一个晚上的时间实现了这个简单的例子，并用C#2.0调试通过，只是为了抛砖引玉。自动生成源代码有很多的方法，但使用CodeDom生成源代码会有更大的灵活性，主要表现在以下三个方面：</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-family: 新宋体;"><span>1.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-family: 新宋体;">语言无关。即只要是.net framework所支持的语言，并且这种语言提供了CodeDomProvider。</span></p>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">就可以生成这种语言的源代码。</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-family: 新宋体;"><span>2.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-family: 新宋体;">如果所生成的语言是测试版或要将这种语言升级到下一个版本，也可以考虑使用CodeDOM。</span></p>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">因为当这种语言的语法有所变化时，CodeDomProvider也会随之升级。因此，使用CodeDOM的Code Wizards也会随着CodeDOM而升级，这样就不必修改Code Wizards的源代码了。</span></p>
<p style="margin-left: 39pt; text-align: left; text-indent: -18pt;" align="left"><span style="font-family: 宋体;"><span>3.<span style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><span style="font-family: 新宋体;">如果所生成的一种语言是你所不熟悉的，如果不使用CodeDOM，必须要熟悉这种语言的语</span></p>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">法，才能生成它的源代码。而使用CodeDOM却可以避免这一点。因为CodeDOM是使用抽象的</span><span style="font-family: 宋体;">object graph</span><span style="font-family: 宋体;">来描述语言的。而语言的具体语法是由CodeDomProvider所决定的。</span></p>
<p style="margin-left: 21pt; text-align: left;" align="left"><span style="font-family: 新宋体;">其实CodeDOM不仅可以用在<span>Code
Wizards</span>上，也可以用在许多其它地方，如可以生成Web </span></p>
<p style="text-align: left;" align="left"><span style="font-family: 新宋体;">Services</span><span style="font-family: 新宋体;">的客户端代理（Client Proxies），或根据UML图生成类的构架代码。总之，使用CodeDom可以大大降低和语言的偶合度，并且很容易维护和升级系统。</span></p>
<br>
</div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory">分类: <a href="http://www.cnblogs.com/nokiaguy/category/137117.html"> 原创</a>, <a href="http://www.cnblogs.com/nokiaguy/category/136726.html">.net高级技术</a>, <a href="http://www.cnblogs.com/nokiaguy/category/135708.html">C#</a></div>
<div id="EntryTag">标签: <a href="http://www.cnblogs.com/nokiaguy/tag/C%23/">C#</a>, <a href="http://www.cnblogs.com/nokiaguy/tag/Code%20Wizards/">Code Wizards</a>, <a href="http://www.cnblogs.com/nokiaguy/tag/CodeDOM/">CodeDOM</a>, <a href="http://www.cnblogs.com/nokiaguy/tag/.net%20framework/">.net framework</a>, <a href="http://www.cnblogs.com/nokiaguy/tag/%E6%95%B0%E6%8D%AE%E8%A1%A8/">数据表</a>, <a href="http://www.cnblogs.com/nokiaguy/tag/%E6%A8%A1%E6%9D%BF%E6%96%87%E4%BB%B6/">模板文件</a></div>
<div id="blog_post_info"><div id="green_channel">
绿色通道：
<a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(1193471,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
<a id="green_channel_follow" onclick="c_follow();" href="javascript:void(0);">关注我</a>
<a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a><a id="green_channel_contact" href="http://space.cnblogs.com/msg/send/%e9%93%b6%e6%b2%b3%e4%bd%bf%e8%80%85" target="_blank">与我联系</a>
<a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/icon_weibo_24.png" alt=""></a>
</div>
<div id="author_profile">
<div id="author_profile_info" class="author_profile_info">
<a href="http://home.cnblogs.com/u/nokiaguy/" target="_blank"><img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/u32818.jpg" class="author_avatar" alt=""></a>
<div id="author_profile_detail" class="author_profile_info">
<a href="http://home.cnblogs.com/u/nokiaguy/">银河使者</a><br>
<a href="http://home.cnblogs.com/u/nokiaguy/followees">关注 - 3</a><br>
<a href="http://home.cnblogs.com/u/nokiaguy/followers">粉丝 - 288</a>
</div>
</div>
<div class="clear"></div>
<div id="author_profile_honor"></div>
<div id="author_profile_follow">
    <a href="javascript:void(0);" onclick="c_follow();return false;">+加关注</a>
</div>
</div>
<div id="div_digg">										
    <div class="diggit" onclick="votePost(1193471,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
	<div class="buryit" onclick="votePost(1193471,&#39;Bury&#39;)"> 
		<span class="burynum" id="bury_count">0</span>
	</div>
	<div class="clear"></div>	
	<div class="diggword" id="digg_tips">
    (请您对文章做出评价)
    </div>	
</div>
</div>
<div class="clear"></div>
<div id="post_next_prev"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193073.html" class="p_n_p_prefix">« </a> 上一篇：<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193073.html" title="发布于2008-05-12 09:37">颠覆C#王权的“魔比斯环” — 实现AOP框架的终极利器</a><br><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193539.html" class="p_n_p_prefix">» </a> 下一篇：<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193539.html" title="发布于2008-05-12 13:20">用C#2.0实现网络蜘蛛(WebSpider)</a><br></div>
</div>


		</div>
		<p class="postfoot">
			posted on <span id="post-date">2008-05-12 12:47</span> <a href="http://www.cnblogs.com/nokiaguy/">银河使者</a> 阅读(<span id="post_view_count">2287</span>) 评论(<span id="post_comment_count">5</span>)  <a href="http://i.cnblogs.com/EditPosts.aspx?postid=1193471" rel="nofollow">编辑</a> <a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#" onclick="AddToWz(1193471);return false;">收藏</a>
		</p>
	</div>
	<script type="text/javascript">var allowComments=true,isLogined=true,cb_blogId=36378,cb_entryId=1193471,cb_blogApp=currentBlogApp,cb_blogUserGuid='9437420b-63cf-dd11-9e4d-001cf0cd104b',cb_entryCreatedDate='2008/5/12 12:47:00';loadViewCount(cb_entryId);</script>
	
	<a name="!comments"></a><div id="blog-comments-placeholder"><div id="comments_pager_top"></div>
<a name="评论"></a>
<div id="comments">
<h3>评论</h3>
	
	
			<div class="post">
				<h2>
					<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#1193489" class="layer">#1楼</a><a name="1193489" id="comment_anchor_1193489"></a>
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1193489,&#39;G/AldpDSB4+b14Ggl2qPqVKSIrhfQD/HoJsXdGZbB0V68WoK7xnA+Q==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1193489,&#39;G/AldpDSB4+b14Ggl2qPqVKSIrhfQD/HoJsXdGZbB0V68WoK7xnA+Q==&#39;)">引用</a></span>
				</h2>
				<div id="comment_body_1193489" class="blog_comment_body"><a href="http://tech.it168.com/m/2007-09-11/200709111500188.shtml" target="_new">http://tech.it168.com/m/2007-09-11/200709111500188.shtml</a>
<br>不知道楼主是不是本人。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1193489,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1193489,&#39;Bury&#39;,this)">反对(0)</a></div><span id="comment_1193489_avatar" style="display:none;">http://pic.cnitblog.com/face/u27711.jpg</span>
				<div class="postfoot">
					 <span class="comment_date">2008-05-12 12:55</span> | <a id="a_comment_author_1193489" href="http://www.cnblogs.com/carysun/" target="_blank">生鱼片</a> <a href="http://msg.cnblogs.com/msg/send/%e7%94%9f%e9%b1%bc%e7%89%87" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
				</div>
			</div>
		
			<div class="post">
				<h2>
					<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#1193496" class="layer">#2楼</a><a name="1193496" id="comment_anchor_1193496"></a>[<span class="louzhu">楼主</span>]
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1193496,&#39;fuBkdIXkRIO+EnWhQa7rsx8syGigdDvGJBfgpcX13grMakcVRIu0wg==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1193496,&#39;fuBkdIXkRIO+EnWhQa7rsx8syGigdDvGJBfgpcX13grMakcVRIu0wg==&#39;)">引用</a></span>
				</h2>
				<div id="comment_body_1193496" class="blog_comment_body">极地圣火是我以前用的网名。哈哈！忘了注明这篇文章以前在IT168发表过了。现在补上。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1193496,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1193496,&#39;Bury&#39;,this)">反对(0)</a></div><span id="comment_1193496_avatar" style="display:none;">http://pic.cnitblog.com/face/u32818.jpg</span>
				<div class="postfoot">
					 <span class="comment_date">2008-05-12 13:00</span> | <a id="a_comment_author_1193496" href="http://www.cnblogs.com/nokiaguy/" target="_blank">银河使者</a> <a href="http://msg.cnblogs.com/msg/send/%e9%93%b6%e6%b2%b3%e4%bd%bf%e8%80%85" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
				</div>
			</div>
		
			<div class="post">
				<h2>
					<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#1193858" class="layer">#3楼</a><a name="1193858" id="comment_anchor_1193858"></a>
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1193858,&#39;&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1193858,&#39;&#39;)">引用</a></span>
				</h2>
				<div id="comment_body_1193858" class="blog_comment_body">总之，使用CodeDom可以大大降低和语言的偶合度，并且很容易维护和升级系统。
<br>竟然有这样的结论...
<br>CodeDom最多能解决基于同一个模型生成不同代码(不过有些语言特性上的东西CodeDom并没有完全支持得到).
<br>如果画几下图结合CodeDom就能把变更搞定..估计现在的CMM,CMMI培训的人早不失业了.
<br></div>
				<div class="postfoot">
					 <span class="comment_date">2008-05-12 16:22</span> | <a id="ctl00_CommentList_NameLink_2" target="_blank">aaaa[未注册用户]</a>
				</div>
			</div>
		
			<div class="post">
				<h2>
					<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#1194299" class="layer">#4楼</a><a name="1194299" id="comment_anchor_1194299"></a>
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1194299,&#39;IeB5ha5J1uvU4/Uz87lHrncaaejxD7mEzZXClnmlmiRaZcZh3bj8og==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1194299,&#39;IeB5ha5J1uvU4/Uz87lHrncaaejxD7mEzZXClnmlmiRaZcZh3bj8og==&#39;)">引用</a></span>
				</h2>
				<div id="comment_body_1194299" class="blog_comment_body">Mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1194299,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1194299,&#39;Bury&#39;,this)">反对(0)</a></div>
				<div class="postfoot">
					 <span class="comment_date">2008-05-13 02:16</span> | <a id="a_comment_author_1194299" href="http://www.cnblogs.com/Sevi/" target="_blank">司域</a> <a href="http://msg.cnblogs.com/msg/send/%e5%8f%b8%e5%9f%9f" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
				</div>
			</div>
		
			<div class="post">
				<h2>
					<a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#1219741" class="layer">#5楼</a><a name="1219741" id="comment_anchor_1219741"></a><span id="comment-maxId" style="display:none;">1219741</span><span id="comment-maxDate" style="display:none;">2008/6/6 10:36:00</span>
					&nbsp;&nbsp;<span class="comment_actions"><a href="javascript:void(0);" onclick="return ReplyComment(1219741,&#39;2DqWi5bAQHQzii44Rmu7lMbuYMuFFnIpYRPaAMqNcHR07TSgK2jvSA==&#39;)">回复</a><a href="javascript:void(0);" onclick="return QuoteComment(1219741,&#39;2DqWi5bAQHQzii44Rmu7lMbuYMuFFnIpYRPaAMqNcHR07TSgK2jvSA==&#39;)">引用</a></span>
				</h2>
				<div id="comment_body_1219741" class="blog_comment_body">学习</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(1219741,&#39;Digg&#39;,this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(1219741,&#39;Bury&#39;,this)">反对(0)</a></div>
				<div class="postfoot">
					 <span class="comment_date">2008-06-06 10:36</span> | <a id="a_comment_author_1219741" href="http://www.cnblogs.com/westhot/" target="_blank">二师兄</a> <a href="http://msg.cnblogs.com/msg/send/%e4%ba%8c%e5%b8%88%e5%85%84" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
				</div>
			</div>
		
</div>
<div id="comments_pager_bottom"></div></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" id="lnk_RefreshComments" onclick="return RefreshCommentList();">刷新评论</a><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#" onclick="return RefreshPage();">刷新页面</a><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#top">返回顶部</a></div>
<div id="comment_form_container"><div id="commentform_title">发表评论</div>
<span id="tip_comment" style="color:Red"></span>
<p>
昵称：<input type="text" id="tbCommentAuthor" class="author" disabled="disabled" size="50" value="window5549-accp">
</p>
<div class="commentbox_main">
<div class="commentbox_title">
<div class="commentbox_title_left">评论内容：</div>
<div class="commentbox_title_right">
<img id="ubb_quote" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/quote.gif" alt="引用" title="添加引用" onclick="insertUBB(&#39;tbCommentBody&#39;,&#39;quote&#39;)">
<img id="ubb_bold" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/b.png" alt="粗体" title="添加粗体" onclick="insertUBB(&#39;tbCommentBody&#39;,&#39;b&#39;)">
<img id="ubb_url" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/lk.png" alt="链接" title="添加链接" onclick="insertUbbUrl(&#39;tbCommentBody&#39;)">
<img id="ubb_indent" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/indent.png" alt="缩进" title="添加首行缩进" onclick="insertIndent(&#39;tbCommentBody&#39;)">
<img id="ubb_code" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/InsertCode.gif" alt="代码" title="添加代码" onclick="insertUbbCode()">
<img id="ubb_img" class="comment_icon" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/img.gif" alt="图片" title="上传图片" onclick="OpenImageUploadWindow();">
</div>
</div>
<div class="clear"></div>
<textarea id="tbCommentBody" class="comment_textarea" rows="20" cols="50"></textarea>
</div>
<p id="commentbox_opt">
<input id="btn_comment_submit" type="button" class="comment_btn" value="提交评论">
<span id="span_comment_canceledit" style="display:none"><a href="javascript:void(0);" onclick="return CancelCommentEdit()">不改了</a></span>
<a href="javascript:void(0);" onclick="return logout();">注销</a>
        <a id="commentbox_opt_sub" href="javascript:void(0);" title="订阅后有新评论时会邮件通知您" onclick="commentManager.Subscribe()">订阅评论</a>
</p>
<p>
[使用Ctrl+Enter键快速提交]
</p>
<div style="display:none">
<span id="comment_edit_id"></span><span id="span_parentcomment_id"></span>
<span id="span_parent_id"></span>
<span id="span_comment_replyto"></span>
<span id="span_comment_posted"></span>
</div>
</div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="site_nav_under"><a href="http://www.imooc.com/view/80?from=cnblogs" target="_blank"><b>【免费课程】案例：用JavaScript实现图片缓慢缩放效果</b></a><br><a href="http://zt.cnblogs.com/tingyun/" target="_blank">听云APP性能监测——终结移动App性能黑洞</a><br><a href="http://oneapm.com/events/ironman.html?hmsr=%E5%8D%9A%E5%AE%A2%E5%9B%AD&hmmd=%E6%96%87%E7%AB%A0%E5%86%85%E9%A1%B5%E6%96%87%E5%AD%97%E9%93%BE&hmpl=&hmkw=&hmci=" target="_blank">100%有礼！机械键盘、钢铁侠T恤免费拿！OneAPM送福利！</a><br><a href="http://www.rongcloud.cn/promotion/" target="_blank">融云，免费为你的App加入IM功能——让你的App“聊”起来！！</a></div>
<div id="opt_under_post"></div>
<script type="text/javascript">
    var enableGoogleAd = canShowAdsense(); var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];
    fixPostBodyFormat();
</script>
<div id="ad_under_post_holder">
<script type="text/javascript">
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function () {
        if (enableGoogleAd) {
            var gads = document.createElement('script');
            gads.async = true;
            gads.type = 'text/javascript';
            var useSSL = 'https:' == document.location.protocol;
            gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
            var node = document.getElementsByTagName('script')[0];
            node.parentNode.insertBefore(gads, node);
        }
    })();
</script>
<script type="text/javascript">
    try {
        if (enableGoogleAd) {
            googletag.cmd.push(function () {
                googletag.defineSlot('/1090369/cnblogs_blogpost_C1_sitehome', [300, 250], 'div-gpt-ad-1346480159711-0').addService(googletag.pubads());
                googletag.defineSlot('/1090369/cnblogs_blogpost_C2', [468, 60], 'div-gpt-ad-1410860226396-0').addService(googletag.pubads());
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
        };
    } catch (e) { }
</script>
<div id="google_ad_c1" class="c_ad_block">
    <div id="div-gpt-ad-1346480159711-0" style="width:300px; height:250px;">
    <script type="text/javascript">
        try {
            if (enableGoogleAd) {
                googletag.cmd.push(function () { googletag.display('div-gpt-ad-1346480159711-0'); });            
            } else {
                $('#div-gpt-ad-1346480159711-0').hide();
            }
    } catch (e) { }
    </script>
    <div id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0" name="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom;"></iframe></div><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__hidden__" name="google_ads_iframe_/1090369/cnblogs_blogpost_C1_sitehome_0__hidden__" width="0" height="0" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom; visibility: hidden; display: none;"></iframe></div>
</div>
</div>
<div id="under_post_news"><div class="itnews c_ad_block"><b>最新IT新闻</b>:<br> ·  <a href="http://news.cnblogs.com/n/504611/" target="_blank">关于编程里的那些ABC</a><br> ·  <a href="http://news.cnblogs.com/n/504626/" target="_blank">我与Surface Pro 3的七天</a><br> ·  <a href="http://news.cnblogs.com/n/504625/" target="_blank">失望！这些新功能与Win9预览版无缘</a><br> ·  <a href="http://news.cnblogs.com/n/504624/" target="_blank">亚马逊为修正虚拟机漏洞重启EC2</a><br> ·  <a href="http://news.cnblogs.com/n/504623/" target="_blank">Vertu中国再发新机：1部换10部iPhone 6</a><br>» <a href="http://news.cnblogs.com/" title="IT新闻" target="_blank">更多新闻...</a></div></div>
<div id="google_ad_c2" class="c_ad_block">
<div id="div-gpt-ad-1410860226396-0" style="width:468px; height:60px;">
<script type="text/javascript">
try {
    if (enableGoogleAd) {
        googletag.cmd.push(function () { googletag.display('div-gpt-ad-1410860226396-0'); });
    } else {
        $('#div-gpt-ad-1346480159711-0').hide();
    }
} catch (e) { }
</script>
<div id="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0" name="google_ads_iframe_/1090369/cnblogs_blogpost_C2_0" width="468" height="60" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:"<html><body style='background:transparent'></body></html>"" style="border: 0px; vertical-align: bottom;"></iframe></div></div>
</div>
<div id="under_post_kb"><div class="itnews c_ad_block" id="kb_block"><b>最新知识库文章</b>:<br><div id="kb_recent"> ·  <a href="http://kb.cnblogs.com/page/504518/" target="_blank">构建高可伸缩性的WEB交互式系统（下）</a><br> ·  <a href="http://kb.cnblogs.com/page/504459/" target="_blank">谈谈网站测试中的AB测试方法</a><br> ·  <a href="http://kb.cnblogs.com/page/504453/" target="_blank">你在支配钱，还是钱在支配你？</a><br> ·  <a href="http://kb.cnblogs.com/page/504360/" target="_blank">关于技术变化方面的五种思想</a><br> ·  <a href="http://kb.cnblogs.com/page/504228/" target="_blank">图解SSL/TLS协议</a><br></div>» <a href="http://kb.cnblogs.com/" target="_blank">更多知识库文章...</a></div></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
$(function () {
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
    setTimeout(function () { incrementViewCount(cb_entryId); }, 200);
});
</script>
</div>

</div>
</div>
<div id="leftmenu">


<h3>导航</h3>
<ul>
<li>
<a id="MyLinks1_HomeLink" href="http://www.cnblogs.com/">博客园</a></li>
<li>
<a id="MyLinks1_MyHomeLink" class="two_words" href="http://www.cnblogs.com/nokiaguy/">首页</a></li>
<li>
<a id="MyLinks1_NewPostLink" rel="nofollow" href="http://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li>
<li>
<a id="MyLinks1_ContactLink" accesskey="9" class="two_words" rel="nofollow" href="http://space.cnblogs.com/msg/send/%e9%93%b6%e6%b2%b3%e4%bd%bf%e8%80%85">联系</a></li>
<li>
<a id="MyLinks1_Syndication" class="two_words" href="http://www.cnblogs.com/nokiaguy/rss">订阅</a>
<a id="MyLinks1_XMLLink" href="http://www.cnblogs.com/nokiaguy/rss"><img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/xml.gif" alt="订阅"></a>
</li>
<li>
<a id="MyLinks1_Admin" class="two_words" rel="nofollow" href="http://i.cnblogs.com/">管理</a></li>
</ul>

<div id="blog-calendar" style=""><table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="日历">
	<tbody><tr><td colspan="7"><table class="CalTitle" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2008/04/01&#39;);return false;">&lt;</a></td><td align="center">2008年5月</td><td class="CalNextPrev" align="right"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2008/06/01&#39;);return false;">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" align="center" abbr="日" scope="col">日</th><th class="CalDayHeader" align="center" abbr="一" scope="col">一</th><th class="CalDayHeader" align="center" abbr="二" scope="col">二</th><th class="CalDayHeader" align="center" abbr="三" scope="col">三</th><th class="CalDayHeader" align="center" abbr="四" scope="col">四</th><th class="CalDayHeader" align="center" abbr="五" scope="col">五</th><th class="CalDayHeader" align="center" abbr="六" scope="col">六</th></tr><tr><td class="CalOtherMonthDay" align="center">27</td><td class="CalOtherMonthDay" align="center">28</td><td class="CalOtherMonthDay" align="center">29</td><td class="CalOtherMonthDay" align="center">30</td><td align="center">1</td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/02.html"><u>2</u></a></td><td class="CalWeekendDay" align="center">3</td></tr><tr><td class="CalWeekendDay" align="center">4</td><td align="center">5</td><td align="center">6</td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/07.html"><u>7</u></a></td><td align="center">8</td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/09.html"><u>9</u></a></td><td class="CalWeekendDay" align="center">10</td></tr><tr><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/11.html"><u>11</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12.html"><u>12</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/13.html"><u>13</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/14.html"><u>14</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/15.html"><u>15</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/16.html"><u>16</u></a></td><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/17.html"><u>17</u></a></td></tr><tr><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/18.html"><u>18</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/19.html"><u>19</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/20.html"><u>20</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/21.html"><u>21</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/22.html"><u>22</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/23.html"><u>23</u></a></td><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/24.html"><u>24</u></a></td></tr><tr><td class="CalWeekendDay" align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/25.html"><u>25</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/26.html"><u>26</u></a></td><td align="center">27</td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/28.html"><u>28</u></a></td><td align="center"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/29.html"><u>29</u></a></td><td align="center">30</td><td class="CalWeekendDay" align="center">31</td></tr><tr><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td><td class="CalOtherMonthDay" align="center">3</td><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td><td class="CalOtherMonthDay" align="center">7</td></tr>
</tbody></table></div><script type="text/javascript">loadBlogDefaultCalendar();</script>
<meta name="vs_showGrid" content="False">

<h3>公告</h3>
<div id="blog-news"><span style="color: #FF0000;">本博客的所有文章，未经说明均为原创，如需转载，请注明出处！</span>
<br><br>
<strong></strong>
<h3 class="boxtitle"><span style="color: red;">个人简介</span>&nbsp;
</h3>
<strong>李宁（银河使者）</strong>：IT作家、讲师、技术顾问，主要研究领域：移动技术、编译器、Linux内核、电子电路。主要著
作：<span style="color: #ff6600;">《Android深度探索（卷1）：HAL与驱动开发》</span><span style="color: #339966;">、《</span><span style="color: #339966;">Android应用开发实战（第2版）》</span>、<span style="color: #993366;">《Android开发完全讲义（第2版）》</span>、《Android开发权威指南（第2版）》、《Android高
薪之路：Android程序员面试宝典 》。<br><br>
<strong>
<h3 class="boxtitle"><span style="color: red;">QQ群</span>&nbsp;
</h3>
游戏开发：264268059
<br>
<br>
<!--<span style="color: blue;">请各位同学加入自己感兴趣的QQ群</span>
<br>
<br>
-->

<h3 class="boxtitle"><span style="color: red;">我的视频课程</span>&nbsp;
</h3>
<strong>
<p>Cocos2d-x 3.0入门与实战视频教程(基于3.0正式版）
</p>
<p>
<a href="http://edu.51cto.com/course/course_id-1227.html"><img alt="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/20140429210606953" height="120" width="175"></a></p></strong>
<br><br>
<h3 class="boxtitle"><span style="color: red;">我的新浪围脖</span>&nbsp;
</h3>
<strong>
<br>
<a href="http://weibo.com/androidguy"><img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/30211130-209df6a265284672a96131b58e245138.png" alt="" height="89" width="185"></a>
<p>&nbsp;</p><strong>
<h3 class="boxtitle"><span style="color: red;">我的著作</span>&nbsp;
</h3>
<p>Android开发权威指南（第2版）[<span style="color:red">火热销售中</span> ]
</p>
<p>
<a href="http://www.amazon.cn/Android%E5%BC%80%E5%8F%91%E6%9D%83%E5%A8%81%E6%8C%87%E5%8D%97-%E6%9D%8E%E5%AE%81/dp/B00EOIDFX8/ref=sr_1_1?ie=UTF8&qid=1378380978&sr=8-1&keywords=android+%E6%9D%8E%E5%AE%81"><img alt="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/05193245-5f70d5ccbc764ee387cb7eb27184f871.png" height="225" width="175"></a></p>
<p>
<a href="http://product.suning.com/104327423.html">【1】苏宁易购（58折）</a></p>
<p>
<a href="http://www.amazon.cn/Android%E5%BC%80%E5%8F%91%E6%9D%83%E5%A8%81%E6%8C%87%E5%8D%97-%E6%9D%8E%E5%AE%81/dp/B00EOIDFX8/ref=sr_1_1?ie=UTF8&qid=1378380978&sr=8-1&keywords=android+%E6%9D%8E%E5%AE%81">【2】亚马逊</a></p>
<p><a href="http://product.dangdang.com/23321534.html#ddclick?act=click&pos=23321534_3_1_q&cat=&key=android%2B%C0%EE%C4%FE&qinfo=30_1_48&pinfo=&minfo=&ninfo=&custid=&permid=20130826174028820239899307364377788&ref=http%3A%2F%2Fwww.dangdang.com%2F&rcount=&type=&t=1378381094000">【3】当当网</a></p>
<p><a href="http://item.jd.com/11306297.html">【4】京东商城</a></p>
<p><a href="http://product.china-pub.com/3802200">【5】互动网</a></p>
<p><a href="http://s.taobao.com/search?q=Android%BF%AA%B7%A2%C8%A8%CD%FE%D6%B8%C4%CF%A3%A8%B5%DA2%B0%E6%A3%A9&suggest=history_1&wq=Android%BF%AA%B7%A2&suggest_query=Android%BF%AA%B7%A2&source=suggest&initiative_id=tbindexz_20130905&spm=1.1000386.5803581.d4908513&sourceId=tb.index&search_type=item&commend=all">【6】淘宝网</a></p>
<p></p>

<br>
<br>
<p>Android深度探索（卷1）：HAL与驱动开发[<span style="color:red">火热销售中</span> ]
</p>
<p>
<a href="http://book.360buy.com/11155655.html"><img alt="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/14215858-813a829d47ef4e37957fcbe9806eeb1b.jpg" height="225" width="175"></a></p>
<p>
<a href="http://product.suning.com/103530430.html">【1】苏宁易购（58折）</a></p>
<p>
<a href="http://www.amazon.cn/Android%E6%B7%B1%E5%BA%A6%E6%8E%A2%E7%B4%A2-HAL%E4%B8%8E%E9%A9%B1%E5%8A%A8%E5%BC%80%E5%8F%91-%E6%9D%8E%E5%AE%81/dp/B00ASIN7L8/ref=sr_1_1?ie=UTF8&qid=1359549360&sr=8-1">【2】亚马逊</a></p>
<p><a href="http://union.dangdang.com/transfer/transfer.aspx?from=P-263982&backurl=http://product.dangdang.com/main/product.aspx?product_id=23043311">【3】当当网</a></p>
<p><a href="http://book.360buy.com/11155655.html">【4】京东商城</a></p>
<p><a href="http://product.china-pub.com/3021757">【5】互动网</a></p>
<p><a href="http://s.taobao.com/search?q=android%C9%EE%B6%C8%CC%BD%CB%F7&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&initiative_id=tbindexz_20130130">【6】淘宝网</a></p>
<p><a href="http://book.douban.com/subject/20480745/">【7】豆瓣网 </a><br>
</p>
<p>
</p>
<p>&nbsp;</p>
<p>Android应用开发实战（第2版）[<span style="color:red">火热销售中</span> ] <br>
</p>
<p>
<a href="http://book.360buy.com/11131468.html"><img src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/30211855-4a9bc7d2b3314d47b9f97c7a3dd3a00e.jpg" alt="" height="227" width="174"></a></p>
<p><a href="http://book.360buy.com/11131468.html">【1】京东商城</a></p>
<p><a href="http://union.dangdang.com/transfer/transfer.aspx?from=P-263982&backurl=http://product.dangdang.com/main/product.aspx?product_id=22915560">【2】当当网</a></p>
<p><a href="http://www.amazon.cn/Android%E5%BA%94%E7%94%A8%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98-%E6%9D%8E%E5%AE%81/dp/B00AAOO42Q/ref=sr_1_6?ie=UTF8&qid=1359550638&sr=8-6">【3】亚马逊</a></p>
<p><a href="http://product.china-pub.com/3020660">【4】互动网</a></p>
<p><a href="http://www.suning.com/emall/prd_10052_22001_-7_4091929_.html">【5】苏宁易购</a></p>
<p><a href="http://s.taobao.com/search?q=Android%D3%A6%D3%C3%BF%AA%B7%A2%CA%B5%D5%BD%A3%A8%B5%DA2%B0%E6%A3%A9&commend=all&ssid=s5-e&search_type=item&sourceId=tb.index&initiative_id=tbindexz_20130130">【6】淘宝网</a></p>
<p><a href="http://book.douban.com/subject/20396237/">【7】豆瓣网 </a><br>
</p>
<p>&nbsp;</p>
<p>Android开发完全讲义（第2版）[<span style="color:red">火热销售中</span> ]&nbsp; <br>
</p>
<p>
<a href="http://book.360buy.com/10994906.html"><img alt="" src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/aa.png" height="225" width="175"></a></p>
<p><a href="http://union.dangdang.com/transfer/transfer.aspx?from=P-263982&backurl=http://product.dangdang.com/main/product.aspx?product_id=22741502">【1】当当网</a></p>
<p><a href="http://www.amazon.cn/Android%E5%BC%80%E5%8F%91%E5%AE%8C%E5%85%A8%E8%AE%B2%E4%B9%89-%E6%9D%8E%E5%AE%81/dp/B00827VLLA/ref=sr_1_2?ie=UTF8&qid=1359550638&sr=8-2">【2】亚马逊</a></p>
<p><a href="http://book.360buy.com/10994906.html">【3】京东商城</a></p>
<p><a href="http://product.china-pub.com/199758">【4】互动网</a></p>
<p><a href="http://s.taobao.com/search?q=Android%BF%AA%B7%A2%CD%EA%C8%AB%BD%B2%D2%E5&initiative_id=staobaoz_20130130">【5】淘宝网</a></p>
<p><a href="http://book.douban.com/subject/10733303/">【6】豆瓣网 </a><br>
</p>
<p>&nbsp;<br>
</p>
<p>&nbsp;</p>
</strong>
<strong>
<p>&nbsp;</p>
<p>&nbsp;</p>
</strong><div id="profile_block">昵称：<a href="http://home.cnblogs.com/u/nokiaguy/">银河使者</a><br>园龄：<a href="http://home.cnblogs.com/u/nokiaguy/" title="入园时间：2008-04-22">6年5个月</a><br>粉丝：<a href="http://home.cnblogs.com/u/nokiaguy/followers/">288</a><br>关注：<a href="http://home.cnblogs.com/u/nokiaguy/followees/">3</a><div id="p_b_follow"><a href="javascript:void(0);" onclick="cnblogs.UserManager.FollowBlogger(&#39;9437420b-63cf-dd11-9e4d-001cf0cd104b&#39;)">+加关注</a></div></div></strong></strong></div><script type="text/javascript">loadBlogNews();</script>

<div id="blog-sidecolumn">
<div class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div id="widget_my_zzk" class="div_my_zzk"><input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk"></div>
<div id="widget_my_google" class="div_my_zzk"><input type="text" name="google_q" id="google_q" onkeydown="return google_go_enter(event)" class="input_my_zzk">&nbsp;<input onclick="google_go()" type="button" value="谷歌搜索" class="btn_my_zzk"></div>
</div>


<h3 class="catListTitle">常用链接</h3>
<ul>
<li><a href="http://www.cnblogs.com/nokiaguy/p/" title="我的博客的随笔列表">我的随笔</a></li><li><a href="http://www.cnblogs.com/nokiaguy/MyComments.html" title="我发表过的评论列表">我的评论</a></li><li><a href="http://www.cnblogs.com/nokiaguy/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li><li><a href="http://www.cnblogs.com/nokiaguy/RecentComments.html" title="我的博客的评论列表">最新评论</a></li><li><a href="http://www.cnblogs.com/nokiaguy/tag/" title="我的博客的标签列表">我的标签</a></li>
</ul>
<div id="itemListLin_con" style="display:none;">

</div>
<h3 class="catListTitle">我的标签</h3>
<div id="MyTag">
<ul>
<li><a href="http://www.cnblogs.com/nokiaguy/tag/android/">android</a>(27)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/java/">java</a>(9)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/linux/">linux</a>(6)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/ophone/">ophone</a>(6)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/%E7%AE%97%E6%B3%95/">算法</a>(6)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a>(4)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/SQL%20Server/">SQL Server</a>(4)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91/">交叉编译</a>(4)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/CodeSourcery/">CodeSourcery</a>(4)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/C%23/">C#</a>(4)</li><li><a href="http://www.cnblogs.com/nokiaguy/tag/">更多</a></li>
</ul>
</div>
		<h3>随笔分类<span style="font-size:11px;font-weight:normal">(280)</span></h3>
		
				<ul>
			
				<li><a id="CatList_LinkList_0_Link_0" href="http://www.cnblogs.com/nokiaguy/category/177252.html">获奖作品(3)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_1" href="http://www.cnblogs.com/nokiaguy/category/137117.html">原创(92)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_2" href="http://www.cnblogs.com/nokiaguy/category/136726.html">.net高级技术(7)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_3" href="http://www.cnblogs.com/nokiaguy/category/136727.html">.net入门技术(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_4" href="http://www.cnblogs.com/nokiaguy/category/139675.html">.net新特性(2)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_5" href="http://www.cnblogs.com/nokiaguy/category/136142.html">ajax(4)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_6" href="http://www.cnblogs.com/nokiaguy/category/135618.html">algorithm(18)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_7" href="http://www.cnblogs.com/nokiaguy/category/250234.html">Android(25)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_8" href="http://www.cnblogs.com/nokiaguy/category/135708.html">C#(13)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_9" href="http://www.cnblogs.com/nokiaguy/category/135889.html">C/C++(13)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_10" href="http://www.cnblogs.com/nokiaguy/category/137462.html">database(11)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_11" href="http://www.cnblogs.com/nokiaguy/category/136315.html">delphi(3)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_12" href="http://www.cnblogs.com/nokiaguy/category/182507.html">IE（6至8）(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_13" href="http://www.cnblogs.com/nokiaguy/category/455402.html">iOS(2)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_14" href="http://www.cnblogs.com/nokiaguy/category/255288.html">Java(15)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_15" href="http://www.cnblogs.com/nokiaguy/category/136144.html">javascript(5)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_16" href="http://www.cnblogs.com/nokiaguy/category/174001.html">linux(10)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_17" href="http://www.cnblogs.com/nokiaguy/category/135707.html">MSIL(2)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_18" href="http://www.cnblogs.com/nokiaguy/category/137461.html">mysql(4)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_19" href="http://www.cnblogs.com/nokiaguy/category/455404.html">Objective-C</a></li>
			
				<li><a id="CatList_LinkList_0_Link_20" href="http://www.cnblogs.com/nokiaguy/category/135890.html">open source(3)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_21" href="http://www.cnblogs.com/nokiaguy/category/538168.html">Python(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_22" href="http://www.cnblogs.com/nokiaguy/category/135420.html">SQL Server(12)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_23" href="http://www.cnblogs.com/nokiaguy/category/138650.html">VBA(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_24" href="http://www.cnblogs.com/nokiaguy/category/136143.html">web(9)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_25" href="http://www.cnblogs.com/nokiaguy/category/177251.html">WPF(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_26" href="http://www.cnblogs.com/nokiaguy/category/174002.html">wxWidgets(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_27" href="http://www.cnblogs.com/nokiaguy/category/133688.html">安全(2)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_28" href="http://www.cnblogs.com/nokiaguy/category/144877.html">进程、线程、并发(5)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_29" href="http://www.cnblogs.com/nokiaguy/category/177027.html">设计模式(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_30" href="http://www.cnblogs.com/nokiaguy/category/174026.html">网络营销(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_31" href="http://www.cnblogs.com/nokiaguy/category/137983.html">宇宙探秘(1)</a></li>
			
				<li><a id="CatList_LinkList_0_Link_32" href="http://www.cnblogs.com/nokiaguy/category/136347.html">杂七杂八(11)</a></li>
			
				</ul>
			
	
		<h3>随笔档案<span style="font-size:11px;font-weight:normal">(146)</span></h3>
		
				<ul>
			
				<li><a id="CatList_LinkList_1_Link_0" href="http://www.cnblogs.com/nokiaguy/archive/2014/08.html">2014年8月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_1" href="http://www.cnblogs.com/nokiaguy/archive/2014/04.html">2014年4月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_2" href="http://www.cnblogs.com/nokiaguy/archive/2013/12.html">2013年12月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_3" href="http://www.cnblogs.com/nokiaguy/archive/2013/11.html">2013年11月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_4" href="http://www.cnblogs.com/nokiaguy/archive/2013/09.html">2013年9月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_5" href="http://www.cnblogs.com/nokiaguy/archive/2013/07.html">2013年7月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_6" href="http://www.cnblogs.com/nokiaguy/archive/2013/06.html">2013年6月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_7" href="http://www.cnblogs.com/nokiaguy/archive/2013/05.html">2013年5月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_8" href="http://www.cnblogs.com/nokiaguy/archive/2013/04.html">2013年4月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_9" href="http://www.cnblogs.com/nokiaguy/archive/2013/03.html">2013年3月 (6)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_10" href="http://www.cnblogs.com/nokiaguy/archive/2013/02.html">2013年2月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_11" href="http://www.cnblogs.com/nokiaguy/archive/2013/01.html">2013年1月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_12" href="http://www.cnblogs.com/nokiaguy/archive/2011/10.html">2011年10月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_13" href="http://www.cnblogs.com/nokiaguy/archive/2011/09.html">2011年9月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_14" href="http://www.cnblogs.com/nokiaguy/archive/2011/04.html">2011年4月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_15" href="http://www.cnblogs.com/nokiaguy/archive/2010/11.html">2010年11月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_16" href="http://www.cnblogs.com/nokiaguy/archive/2010/10.html">2010年10月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_17" href="http://www.cnblogs.com/nokiaguy/archive/2010/09.html">2010年9月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_18" href="http://www.cnblogs.com/nokiaguy/archive/2010/08.html">2010年8月 (5)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_19" href="http://www.cnblogs.com/nokiaguy/archive/2010/07.html">2010年7月 (8)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_20" href="http://www.cnblogs.com/nokiaguy/archive/2010/06.html">2010年6月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_21" href="http://www.cnblogs.com/nokiaguy/archive/2010/05.html">2010年5月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_22" href="http://www.cnblogs.com/nokiaguy/archive/2010/04.html">2010年4月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_23" href="http://www.cnblogs.com/nokiaguy/archive/2010/03.html">2010年3月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_24" href="http://www.cnblogs.com/nokiaguy/archive/2010/01.html">2010年1月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_25" href="http://www.cnblogs.com/nokiaguy/archive/2009/12.html">2009年12月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_26" href="http://www.cnblogs.com/nokiaguy/archive/2009/11.html">2009年11月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_27" href="http://www.cnblogs.com/nokiaguy/archive/2009/09.html">2009年9月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_28" href="http://www.cnblogs.com/nokiaguy/archive/2009/08.html">2009年8月 (1)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_29" href="http://www.cnblogs.com/nokiaguy/archive/2009/07.html">2009年7月 (2)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_30" href="http://www.cnblogs.com/nokiaguy/archive/2009/06.html">2009年6月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_31" href="http://www.cnblogs.com/nokiaguy/archive/2009/03.html">2009年3月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_32" href="http://www.cnblogs.com/nokiaguy/archive/2009/02.html">2009年2月 (6)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_33" href="http://www.cnblogs.com/nokiaguy/archive/2009/01.html">2009年1月 (5)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_34" href="http://www.cnblogs.com/nokiaguy/archive/2008/12.html">2008年12月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_35" href="http://www.cnblogs.com/nokiaguy/archive/2008/10.html">2008年10月 (4)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_36" href="http://www.cnblogs.com/nokiaguy/archive/2008/09.html">2008年9月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_37" href="http://www.cnblogs.com/nokiaguy/archive/2008/08.html">2008年8月 (3)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_38" href="http://www.cnblogs.com/nokiaguy/archive/2008/07.html">2008年7月 (6)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_39" href="http://www.cnblogs.com/nokiaguy/archive/2008/06.html">2008年6月 (9)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_40" href="http://www.cnblogs.com/nokiaguy/archive/2008/05.html">2008年5月 (36)</a></li>
			
				<li><a id="CatList_LinkList_1_Link_41" href="http://www.cnblogs.com/nokiaguy/archive/2008/04.html">2008年4月 (1)</a></li>
			
				</ul>
			
	
		<h3>相册</h3>
		
				<ul>
			
				<li><a id="CatList_LinkList_2_Link_0" href="http://www.cnblogs.com/nokiaguy/gallery/136562.html" rel="nofollow">images</a></li>
			
				<li><a id="CatList_LinkList_2_Link_1" href="http://www.cnblogs.com/nokiaguy/gallery/139674.html" rel="nofollow">其他</a></li>
			
				<li><a id="CatList_LinkList_2_Link_2" href="http://www.cnblogs.com/nokiaguy/gallery/136978.html" rel="nofollow">微软认证</a></li>
			
				</ul>
			
	
<h3>积分与排名</h3>
<ul>
	<li>
		积分 -
		350443
	</li><li>
		排名 -
		250
	</li>
</ul>
<div id="recent_comments_wrap">
<h3 class="catListTitle">最新评论</h3>
<div class="RecentComment" id="RecentComments">
	<div id="RecentCommentsBlock"><ul>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/06/02/1212359.html#3030868">1. Re:用Office VBA实现多控件一次性组合</a></li>
    <li class="recent_comment_body">VBA怎么转成C#代码呀？</li>
    <li class="recent_comment_author">--CodeHunter</li>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html#3018760">2. Re:C#线程系列讲座(1)：BeginInvoke和EndInvoke方法</a></li>
    <li class="recent_comment_body">看到1/3就忍不住想点赞了，清晰明了！</li>
    <li class="recent_comment_author">--wzStyle</li>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/nokiaguy/p/3929587.html#3016777">3. Re:据说有99%的人都会做错的面试题</a></li>
    <li class="recent_comment_body"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#3016591" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3016591);">@</a>garbageMan<br>10^4怎么了，错了？要指出错误就说明白点！</li>
    <li class="recent_comment_author">--银河使者</li>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/nokiaguy/p/3929587.html#3016591">4. Re:据说有99%的人都会做错的面试题</a></li>
    <li class="recent_comment_body"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#3015926" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3015926);">@</a>银河使者<br>我说的是<b>10</b>^4</li>
    <li class="recent_comment_author">--garbageMan</li>
    <li class="recent_comment_title"><a href="http://www.cnblogs.com/nokiaguy/p/3929587.html#3015926">5. Re:据说有99%的人都会做错的面试题</a></li>
    <li class="recent_comment_body"><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/12/1193471.html#3015795" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3015795);">@</a>garbageMan<br>这是没错的，不信自己算算。</li>
    <li class="recent_comment_author">--银河使者</li>
</ul>
</div>
</div>
</div><div id="topview_posts_wrap">
<h3 class="catListTitle">阅读排行榜</h3>
<div class="RecentComment" id="TopViewPosts"> 
	<div id="TopViewPostsBlock"><ul><li><a href="http://www.cnblogs.com/nokiaguy/archive/2010/08/15/1799944.html">1. 哈佛大学凌晨4点半的景象(52432)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/11/1191914.html">2. 全排列算法原理和实现(50936)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html">3. C#线程系列讲座(1)：BeginInvoke和EndInvoke方法(25660)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2010/08/23/1806870.html">4. 可循环显示图像的Android Gallery组件(21182)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/07/16/1244746.html">5. C#线程系列讲座(2)：Thread类的应用(12795)</a></li></ul></div>
</div>
</div><div id="topfeedback_posts_wrap">
<h3 class="catListTitle">评论排行榜</h3>
<div class="RecentComment" id="TopCommentsPosts">
	<div id="TopFeedbackPostsBlock"><ul><li><a href="http://www.cnblogs.com/nokiaguy/archive/2013/01/29/2881476.html">1. 百度面试题：求绝对值最小的数(87)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2010/03/23/1692170.html">2. Google搜索服务退出中国(55)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/p/3691921.html">3. 一道淘汰85%面试者的百度开发者面试题(44)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/04/28/1174529.html">4. 用VC实现洪水攻击程序(39)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html">5. C#线程系列讲座(1)：BeginInvoke和EndInvoke方法(36)</a></li></ul></div>
</div></div><div id="topdigg_posts_wrap">
<h3 class="catListTitle">推荐排行榜</h3>
<div class="RecentComment">
	<div id="TopDiggPostsBlock"><ul><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/07/13/1241817.html">1. C#线程系列讲座(1)：BeginInvoke和EndInvoke方法(17)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2010/08/23/1806870.html">2. 可循环显示图像的Android Gallery组件(12)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2010/08/15/1799944.html">3. 哈佛大学凌晨4点半的景象(12)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2008/05/11/1191914.html">4. 全排列算法原理和实现(10)</a></li><li><a href="http://www.cnblogs.com/nokiaguy/archive/2013/03/12/2955128.html">5. 疯狂极客前传：用最快的速度设计一种新的编程语言(7)</a></li></ul></div>
</div></div></div><script type="text/javascript">loadBlogSideColumn();</script><iframe src="./使用.Net的CodeDOM技术实现语言无关的Code Wizard - 银河使者 - 博客园_files/container.htm" style="visibility: hidden; display: none;"></iframe>

</div>
</div>
<div class="clear"></div>
<div id="footer">

<p id="footer">
	Powered by: 
	<br>
	
	<a id="Footer1_Hyperlink3" name="Hyperlink1" href="http://www.cnblogs.com/" style="font-family:Verdana;font-size:12px;">博客园</a>
	<br>
	Copyright © 银河使者
</p>
</div>
</div>



<iframe id="google_osd_static_frame_2234160464722" name="google_osd_static_frame" style="display: none; width: 0px; height: 0px;"></iframe></body></html>